package jtk.project4.fleet.field;
//By : Swandi Naibaho
//NIM : 091511031
//Kelas : 2A
import java.awt.Dimension;
import java.text.NumberFormat;
import java.text.SimpleDateFormat;

import javax.swing.text.NumberFormatter;

import jtk.project4.fleet.domain.Fuel;

import nl.coderight.jazz.form.FormLayout;
import nl.coderight.jazz.form.control.CalendarControl;
import nl.coderight.jazz.form.control.GroupControl;
import nl.coderight.jazz.form.field.ComboField;
import nl.coderight.jazz.form.field.NumberField;
import nl.coderight.jazz.form.field.TextField;
import nl.coderight.jazz.form.field.button.PushButton;
import nl.coderight.jazz.form.field.input.InputFieldFormatter;

public class AddEditFuelEntryField extends GroupControl<Fuel> {
	private CalendarControl PurchaseDateField;
	private TextField FillMileageField;
	private TextField GallonConsumedField;
	private TextField MPGField;
	private TextField PriceperGallonField;
	private TextField TotalCostField;
	private ComboField<String> StateField;
	private ComboField<String> FuelTypeField; 
	private ComboField<String> BrandField;
	private ComboField<String> VendorField;
	private PushButton AddField;
	private ComboField<String> DriverField;
	private ComboField<String> StockTankField;
	private ComboField<String> CostCenterField;
	private TextField CommentsField;
	
	public AddEditFuelEntryField(String bindID){
		setTitle("header.AddEditFuelEntry"); //disesuaikan dengan nama field
		setBindID(bindID);
		createFields();
		createLayout();
	}
	//private GroupControl createForm(){
		
	//}
	
	private void createFields()
	{
		Dimension dimension = new Dimension(166, 20);
		PurchaseDateField = new CalendarControl("date", 20);
		PurchaseDateField.setFormat(new SimpleDateFormat(translate("yyyy-MM-dd")));
		PurchaseDateField.showYearSpinner(true);
		
		PurchaseDateField.setPreferredSize(dimension);
		
		FillMileageField = new TextField("diffUnits", 20);
		
		GallonConsumedField = new TextField("consumed", 20);
		
		MPGField = new TextField("empId", 20);
		
		PriceperGallonField = new TextField("price", 20);
		
		TotalCostField = new TextField("totalCost", 20);
		
		StateField = new ComboField<String>("state","");
		StateField.setPreferredSize(dimension);
		
		FuelTypeField = new ComboField<String>("fuelType","");
		FuelTypeField.setPreferredSize(dimension);
		
		BrandField = new ComboField<String>("brand","");
		BrandField.setPreferredSize(dimension);
		
		VendorField = new ComboField<String>("vendorId","");
		VendorField.setPreferredSize(dimension);
		
		AddField = new PushButton("...");
		
		DriverField = new ComboField<String>("usageRate","");
		DriverField.setPreferredSize(dimension);
		
		StockTankField = new ComboField<String>("tankId","");
		StockTankField.setPreferredSize(dimension);
		
		CostCenterField = new ComboField<String>("costCenter","");
		CostCenterField.setPreferredSize(dimension);
		
		CommentsField = new TextField("comments", 20);
	}
	
	private void createLayout()
	{
		setLayout(new FormLayout())

		.addLabel("Purchase Date:")	 .addField(PurchaseDateField)
		.addRow()
		.addLabel("Fill Mileage :")	 .addField(FillMileageField)
		.addRow()
		.addLabel("Gallon Consumed :") .addField(GallonConsumedField)
		.addRow()
		.addLabel("MPG :")			 .addField(MPGField)
		.addRow()
		.addLabel("Price per Gallon :").addField(PriceperGallonField)
		.addRow()
		.addLabel("Total Cost :")		 .addField(TotalCostField)
		.addRow()
		.addLabel("State :")			 .addField(StateField)
		.addRow()
		.addLabel("Fuel Type :")		 .addField(FuelTypeField)
		.addRow()
		.addLabel("Brand :")		 	 .addField(BrandField)
		.addRow()
		.addLabel("Vendor :")		 	 .addField(VendorField)
		.addLabel("")						 .addField(AddField)
		.addRow()
		.addLabel("Driver :")		 	 .addField(DriverField)
		.addRow()
		.addLabel("Stock Tank :")		 .addField(StockTankField)
		.addRow()
		.addLabel("Cost Center :")	 .addField(CostCenterField)
		.addRow()
		.addLabel("Comments :")		 .addField(CommentsField);
	}
}
